package cn.blunce.timebroadcast;

import android.app.IntentService;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Vibrator;
import android.util.Log;


public class AlarmIntentService extends IntentService {
    public AlarmIntentService() {
        super("AlarmIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        if (intent.getBooleanExtra(MainActivity.IS_VOICE, false)) {
            MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.alarm);
            mediaPlayer.start();
        }

        if (intent.getBooleanExtra(MainActivity.IS_VIBRATE, true)) {
            Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
            vibrator.vibrate(100);
        }
        Log.i("AlarmTest", "Repeat alarm is ringing.");
    }

}
